<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK hide #-}</span><span>
</span><span id="line-3"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Distribution.Compat.Internal.TempFile</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-4"></span><span>  </span><span class="annot"><a href="../../base/src/System.IO.html#openTempFile"><span class="hs-identifier">openTempFile</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-5"></span><span>  </span><span class="annot"><a href="../../base/src/System.IO.html#openBinaryTempFile"><span class="hs-identifier">openBinaryTempFile</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-6"></span><span>  </span><span class="annot"><a href="Distribution.Compat.Internal.TempFile.html#openNewBinaryFile"><span class="hs-identifier">openNewBinaryFile</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-7"></span><span>  </span><span class="annot"><a href="Distribution.Compat.Internal.TempFile.html#createTempDirectory"><span class="hs-identifier">createTempDirectory</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-8"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Compat.Exception.html"><span class="hs-identifier">Distribution.Compat.Exception</span></a></span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.html#"><span class="hs-identifier">System.FilePath</span></a></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator">(&lt;/&gt;)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>              </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#openTempFile"><span class="hs-identifier">openTempFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#openBinaryTempFile"><span class="hs-identifier">openBinaryTempFile</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if defined(__IO_MANAGER_WINIO__)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>              </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.html#openBinaryTempFileWithDefaultPermissions"><span class="hs-identifier">openBinaryTempFileWithDefaultPermissions</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Exception</span><span>      </span><span class="hs-special">(</span><span class="hs-identifier">onException</span><span class="hs-special">)</span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Bits</span><span>              </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-operator">.|.</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C</span><span>              </span><span class="hs-special">(</span><span class="hs-identifier">CInt</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">eEXIST</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getErrno</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">errnoToIOError</span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.IO.Handle.FD</span><span>       </span><span class="hs-special">(</span><span class="hs-identifier">fdToHandle</span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Posix.Internals</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">c_open</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">c_close</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">o_EXCL</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">o_BINARY</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withFilePath</span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>                               </span><span class="hs-identifier">o_CREAT</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">o_RDWR</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">o_NONBLOCK</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">o_NOCTTY</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.Posix.Internals.html#"><span class="hs-identifier">System.Posix.Internals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.Posix.Internals.html#c_getpid"><span class="hs-identifier">c_getpid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#"><span class="hs-identifier">System.IO.Error</span></a></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.Error.html#isAlreadyExistsError"><span class="hs-identifier">isAlreadyExistsError</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if defined(mingw32_HOST_OS) || defined(ghcjs_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#"><span class="hs-identifier">System.Directory</span></a></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#createDirectory"><span class="hs-identifier">createDirectory</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="hs-identifier">System.Posix</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-35"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-36"></span><span class="hs-comment">-- * temporary files</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">-- This is here for Haskell implementations that do not come with</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- System.IO.openTempFile. This includes nhc-1.20, hugs-2006.9.</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- TODO: This file should probably be removed.</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-comment">-- This is a copy/paste of the openBinaryTempFile definition, but</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- it uses 666 rather than 600 for the permissions. Newer versions</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- of base have a new function with this behavior which we use on</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- Windows when the new IO manager is used.</span><span>
</span><span id="line-47"></span><span class="annot"><a href="Distribution.Compat.Internal.TempFile.html#openNewBinaryFile"><span class="hs-identifier hs-type">openNewBinaryFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span id="openNewBinaryFile"><span class="annot"><span class="annottext">openNewBinaryFile :: FilePath -&gt; FilePath -&gt; IO (FilePath, Handle)
</span><a href="Distribution.Compat.Internal.TempFile.html#openNewBinaryFile"><span class="hs-identifier hs-var hs-var">openNewBinaryFile</span></a></span></span><span> </span><span id="local-6989586621679612287"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612287"><span class="hs-identifier hs-var">dir</span></a></span></span><span> </span><span id="local-6989586621679612286"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612286"><span class="hs-identifier hs-var">template</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-49"></span><span>  </span><span class="hs-comment">-- This method can't be used under WINIO. Also the current implementation has</span><span>
</span><span id="line-50"></span><span>  </span><span class="hs-comment">-- thread safety issues depending on which GHC is used.  On newer GHC's let's</span><span>
</span><span id="line-51"></span><span>  </span><span class="hs-comment">-- use the built in one.</span><span class="hs-cpp">
#if defined(__IO_MANAGER_WINIO__)
</span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; IO (FilePath, Handle)
</span><a href="../../base/src/System.IO.html#openBinaryTempFileWithDefaultPermissions"><span class="hs-identifier hs-var">openBinaryTempFileWithDefaultPermissions</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612287"><span class="hs-identifier hs-var">dir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612286"><span class="hs-identifier hs-var">template</span></a></span><span class="hs-cpp">
#else
</span><span>  </span><span class="hs-identifier">pid</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">c_getpid</span><span>
</span><span id="line-56"></span><span>  </span><span class="hs-identifier">findTempName</span><span> </span><span class="hs-identifier">pid</span><span>
</span><span id="line-57"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-58"></span><span>    </span><span class="hs-comment">-- We split off the last extension, so we can use .foo.ext files</span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-comment">-- for temporary files (hidden on Unix OSes). Unfortunately we're</span><span>
</span><span id="line-60"></span><span>    </span><span class="hs-comment">-- below file path in the hierarchy here.</span><span>
</span><span id="line-61"></span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">prefix</span><span class="hs-special">,</span><span class="hs-identifier">suffix</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-62"></span><span>       </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">break</span><span> </span><span class="hs-special">(</span><span class="hs-operator">==</span><span> </span><span class="hs-char">'.'</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">reverse</span><span> </span><span class="hs-identifier">template</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-63"></span><span>         </span><span class="hs-comment">-- First case: template contains no '.'s. Just re-reverse it.</span><span>
</span><span id="line-64"></span><span>         </span><span class="hs-special">(</span><span class="hs-identifier">rev_suffix</span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;&quot;</span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">reverse</span><span> </span><span class="hs-identifier">rev_suffix</span><span class="hs-special">,</span><span> </span><span class="hs-string">&quot;&quot;</span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span>         </span><span class="hs-comment">-- Second case: template contains at least one '.'. Strip the</span><span>
</span><span id="line-66"></span><span>         </span><span class="hs-comment">-- dot from the prefix and prepend it to the suffix (if we don't</span><span>
</span><span id="line-67"></span><span>         </span><span class="hs-comment">-- do this, the unique number will get added after the '.' and</span><span>
</span><span id="line-68"></span><span>         </span><span class="hs-comment">-- thus be part of the extension, which is wrong.)</span><span>
</span><span id="line-69"></span><span>         </span><span class="hs-special">(</span><span class="hs-identifier">rev_suffix</span><span class="hs-special">,</span><span> </span><span class="hs-char">'.'</span><span class="hs-glyph">:</span><span class="hs-identifier">rest</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">reverse</span><span> </span><span class="hs-identifier">rest</span><span class="hs-special">,</span><span> </span><span class="hs-char">'.'</span><span class="hs-glyph">:</span><span class="hs-identifier">reverse</span><span> </span><span class="hs-identifier">rev_suffix</span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span>         </span><span class="hs-comment">-- Otherwise, something is wrong, because (break (== '.')) should</span><span>
</span><span id="line-71"></span><span>         </span><span class="hs-comment">-- always return a pair with either the empty string or a string</span><span>
</span><span id="line-72"></span><span>         </span><span class="hs-comment">-- beginning with '.' as the second component.</span><span>
</span><span id="line-73"></span><span>         </span><span class="hs-identifier">_</span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">error</span><span> </span><span class="hs-string">&quot;bug in System.IO.openTempFile&quot;</span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span>    </span><span class="hs-identifier">oflags</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">rw_flags</span><span> </span><span class="hs-operator">.|.</span><span> </span><span class="hs-identifier">o_EXCL</span><span> </span><span class="hs-operator">.|.</span><span> </span><span class="hs-identifier">o_BINARY</span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span>    </span><span class="hs-identifier">findTempName</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-78"></span><span>      </span><span class="hs-identifier">fd</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">withFilePath</span><span> </span><span class="hs-identifier">filepath</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-79"></span><span>              </span><span class="hs-identifier">c_open</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">oflags</span><span> </span><span class="hs-number">0o666</span><span>
</span><span id="line-80"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-operator">&lt;</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-81"></span><span>       </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-82"></span><span>         </span><span class="hs-identifier">errno</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getErrno</span><span>
</span><span id="line-83"></span><span>         </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">errno</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">eEXIST</span><span>
</span><span id="line-84"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="hs-identifier">findTempName</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">x</span><span class="hs-operator">+</span><span class="hs-number">1</span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="hs-identifier">ioError</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">errnoToIOError</span><span> </span><span class="hs-string">&quot;openNewBinaryFile&quot;</span><span> </span><span class="hs-identifier">errno</span><span> </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">dir</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-87"></span><span>         </span><span class="hs-comment">-- TODO: We want to tell fdToHandle what the file path is,</span><span>
</span><span id="line-88"></span><span>         </span><span class="hs-comment">-- as any exceptions etc will only be able to report the</span><span>
</span><span id="line-89"></span><span>         </span><span class="hs-comment">-- FD currently</span><span>
</span><span id="line-90"></span><span>         </span><span class="hs-identifier">h</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">fdToHandle</span><span> </span><span class="hs-identifier">fd</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">onException</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">c_close</span><span> </span><span class="hs-identifier">fd</span><span>
</span><span id="line-91"></span><span>         </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">filepath</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">h</span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-93"></span><span>        </span><span class="hs-identifier">filename</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">prefix</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">show</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">suffix</span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-identifier">filepath</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">dir</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">combine</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">filename</span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-comment">-- FIXME: bits copied from System.FilePath</span><span>
</span><span id="line-97"></span><span>        </span><span class="hs-identifier">combine</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-98"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">b</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">a</span><span>
</span><span id="line-99"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-100"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">last</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">pathSeparator</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-101"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">pathSeparator</span><span class="hs-special">]</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-102"></span><span>
</span><span id="line-103"></span><span class="hs-comment">-- FIXME: Copied from GHC.Handle</span><span>
</span><span id="line-104"></span><span class="hs-identifier">std_flags</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">output_flags</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">rw_flags</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">CInt</span><span>
</span><span id="line-105"></span><span class="hs-identifier">std_flags</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">o_NONBLOCK</span><span>   </span><span class="hs-operator">.|.</span><span> </span><span class="hs-identifier">o_NOCTTY</span><span>
</span><span id="line-106"></span><span class="hs-identifier">output_flags</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">std_flags</span><span>    </span><span class="hs-operator">.|.</span><span> </span><span class="hs-identifier">o_CREAT</span><span>
</span><span id="line-107"></span><span class="hs-identifier">rw_flags</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">output_flags</span><span> </span><span class="hs-operator">.|.</span><span> </span><span class="hs-identifier">o_RDWR</span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-comment">-- FIXME: Should use System.FilePath library</span><span>
</span><span id="line-110"></span><span class="hs-identifier">pathSeparator</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Char</span><span class="hs-cpp">
#ifdef mingw32_HOST_OS
</span><span class="hs-identifier">pathSeparator</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-char">'\\'</span><span class="hs-cpp">
#else
</span><span class="hs-identifier">pathSeparator</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-char">'/'</span><span class="hs-cpp">
#endif
</span><span class="hs-comment">-- /* __IO_MANAGER_WINIO__ */</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-119"></span><span class="annot"><a href="Distribution.Compat.Internal.TempFile.html#createTempDirectory"><span class="hs-identifier hs-type">createTempDirectory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span>
</span><span id="line-120"></span><span id="createTempDirectory"><span class="annot"><span class="annottext">createTempDirectory :: FilePath -&gt; FilePath -&gt; IO FilePath
</span><a href="Distribution.Compat.Internal.TempFile.html#createTempDirectory"><span class="hs-identifier hs-var hs-var">createTempDirectory</span></a></span></span><span> </span><span id="local-6989586621679612285"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612285"><span class="hs-identifier hs-var">dir</span></a></span></span><span> </span><span id="local-6989586621679612284"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612284"><span class="hs-identifier hs-var">template</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-121"></span><span>  </span><span id="local-6989586621679612283"><span class="annot"><span class="annottext">CPid
</span><a href="#local-6989586621679612283"><span class="hs-identifier hs-var">pid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO CPid
</span><a href="../../base/src/System.Posix.Internals.html#c_getpid"><span class="hs-identifier hs-var">c_getpid</span></a></span><span>
</span><span id="line-122"></span><span>  </span><span class="annot"><span class="annottext">CPid -&gt; IO FilePath
forall {t}. (Num t, Show t) =&gt; t -&gt; IO FilePath
</span><a href="#local-6989586621679612282"><span class="hs-identifier hs-var">findTempName</span></a></span><span> </span><span class="annot"><span class="annottext">CPid
</span><a href="#local-6989586621679612283"><span class="hs-identifier hs-var">pid</span></a></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-124"></span><span>    </span><span id="local-6989586621679612282"><span class="annot"><span class="annottext">findTempName :: t -&gt; IO FilePath
</span><a href="#local-6989586621679612282"><span class="hs-identifier hs-var hs-var">findTempName</span></a></span></span><span> </span><span id="local-6989586621679612275"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679612275"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-125"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679612273"><span class="annot"><span class="annottext">dirpath :: FilePath
</span><a href="#local-6989586621679612273"><span class="hs-identifier hs-var hs-var">dirpath</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612285"><span class="hs-identifier hs-var">dir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C%2F%3E"><span class="hs-operator hs-var">&lt;/&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612284"><span class="hs-identifier hs-var">template</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;-&quot;</span></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; FilePath -&gt; FilePath
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">t -&gt; FilePath
forall a. Show a =&gt; a -&gt; FilePath
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679612275"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-126"></span><span>      </span><span id="local-6989586621679612271"><span class="annot"><span class="annottext">Either IOException ()
</span><a href="#local-6989586621679612271"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO (Either IOException ())
forall a. IO a -&gt; IO (Either IOException a)
</span><a href="Distribution.Compat.Exception.html#tryIO"><span class="hs-identifier hs-var">tryIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO (Either IOException ()))
-&gt; IO () -&gt; IO (Either IOException ())
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="Distribution.Compat.Internal.TempFile.html#mkPrivateDir"><span class="hs-identifier hs-var">mkPrivateDir</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612273"><span class="hs-identifier hs-var">dirpath</span></a></span><span>
</span><span id="line-127"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either IOException ()
</span><a href="#local-6989586621679612271"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-128"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO FilePath
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612273"><span class="hs-identifier hs-var">dirpath</span></a></span><span>
</span><span id="line-129"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span>  </span><span id="local-6989586621679612268"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679612268"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isAlreadyExistsError"><span class="hs-identifier hs-var">isAlreadyExistsError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679612268"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">t -&gt; IO FilePath
</span><a href="#local-6989586621679612282"><span class="hs-identifier hs-var">findTempName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679612275"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO FilePath
forall a. IOException -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679612268"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="annot"><a href="Distribution.Compat.Internal.TempFile.html#mkPrivateDir"><span class="hs-identifier hs-type">mkPrivateDir</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS) || defined(ghcjs_HOST_OS)
</span><span id="mkPrivateDir"><span class="annot"><span class="annottext">mkPrivateDir :: FilePath -&gt; IO ()
</span><a href="Distribution.Compat.Internal.TempFile.html#mkPrivateDir"><span class="hs-identifier hs-var hs-var">mkPrivateDir</span></a></span></span><span> </span><span id="local-6989586621679612265"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612265"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO ()
</span><a href="../../directory/src/System.Directory.html#createDirectory"><span class="hs-identifier hs-var">createDirectory</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679612265"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-identifier">mkPrivateDir</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">System.Posix.createDirectory</span><span> </span><span class="hs-identifier">s</span><span> </span><span class="hs-number">0o700</span><span class="hs-cpp">
#endif
</span></pre></body></html>